package com.jiangruan.javaPro;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaPro.address.BitCoinAddress;
import com.jiangruan.javaPro.bean.HotVideoCommon;
import com.jiangruan.javaPro.net.HttpUtils;
import com.jiangruan.javaPro.service.GetBestBlockHashService;

import java.security.KeyPair;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @Author: 冷风诉离歌
 * @Description:  
 * @Date: 2021/12/12 19:40
 * @Desc:
 * @ReturnType: 
 */

public class Main {
    public static void main(String[] args) {

        new Main().run();

    }
    public void run(){
        System.out.println("Java期末作业");
        System.out.println("当前程序完成的功能");
        System.out.println("1.热门视频数据抓取2.比特币客户端通信3.原始格式推导0.退出 ");
        while (true){
            menu();
        }
    }
    public void menu(){
        System.out.println("请输入要使用的功能");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num) {
            case 1:
                String url = Constants.TRIP_URL
                        + "?key="
                        + Constants.TRIP_KEY
                        + "&type=hot_video"
                        + "&size = 10";
                String result = HttpUtils.get(url);
                System.out.println(result);
                break;
            case 2:
                GetBestBlockHashService getBestBlockHashService = new GetBestBlockHashService();
                getBestBlockHashService.getBestBlockHash();
                break;
            case 3:
                BitCoinAddress add = new BitCoinAddress();
                KeyPair keyPair = add.generateKey();
                String address = add.newAddress(keyPair);
                if(add.validateAddress(address)){
                    System.out.println("新生成的比特币地址："+address);
                }else {
                    System.out.println("错误");
                }
                break;
            case 0:
                System.exit(0);
            default:
                System.out.println("不支持的功能，请重试");
                break;
        }
    }
}
